﻿using System;
using System.Collections.Generic;
using System.Text;
using log4net.Config;
using log4net.Extensions.Appender.XMPP;
using log4net.Extensions.Appender.Web;

namespace TestApplication
{
    class Program
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
        static string GetValueFromConsole(string Text)
        {

            string value = null;

            while (value == null)
            {
                Console.WriteLine(Text);
                value = Console.ReadLine();
            }

            return value;
        }

        static void Main(string[] args)
        {
            log4net.Util.LogLog.InternalDebugging = true;
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("logging.config"));

            WebServiceAppender appender = new WebServiceAppender();
            appender.ServiceUrl = "http://localhost:50464/Log4net.asmx";
            appender.Layout = new log4net.Layout.SimpleLayout();
            

            //XMPPChatroomAppender appender = new XMPPChatroomAppender();
            //appender.Server = GetValueFromConsole("Server:");
            //appender.UserName = GetValueFromConsole("Username:");
            //appender.Password = GetValueFromConsole("Password:");
            //appender.ChatRoom = GetValueFromConsole("Chatroom:");
            //appender.Layout = new log4net.Layout.SimpleLayout();
            //appender.AddMapping(new XMPPAppender.LevelColors() { BackColor = "#FFFF00", ForeColor = "#000000", Level = log4net.Core.Level.Warn });
            //appender.AddMapping(new XMPPAppender.LevelColors() { BackColor = "#FF0000", ForeColor = "#000000", Level = log4net.Core.Level.Error });
            //appender.ActivateOptions();

            BasicConfigurator.Configure(appender);

            while (true)
            {
                string value = GetValueFromConsole("Enter something to send.");
                if (log.IsInfoEnabled) log.Info(value);
                if (log.IsErrorEnabled) log.Error(value);
                if (log.IsWarnEnabled) log.Warn(value);
            }

            log4net.LogManager.Shutdown();
            
        }
    }
}
